// To parse this JSON data, do
//
//     final BaseResponseModel = baseResponseModelFromJson(jsonString);

import 'dart:convert';

import 'package:common/constant/http_constant.dart';
import 'package:resource/generated/l10n.dart';

import '../constant/constant.dart';

CodeMsgModel baseResponseModelFromJson(String str) => CodeMsgModel.fromMap(json.decode(str));

String baseResponseModelToJson(CodeMsgModel data) => json.encode(data.toMap());

class CodeMsgModel {
  String? code;
  String? msg;

  CodeMsgModel([
     this.code,
     this.msg]
  );

  factory CodeMsgModel.fromMap(Map<String, dynamic> json) => CodeMsgModel(
    json[HttpConstant.codeKey],
    json[HttpConstant.msgKey],
  );

  Map<String, dynamic> toMap() => {
    HttpConstant.codeKey: code,
    HttpConstant.msgKey: msg,
  };

  static CodeMsgModel success(){
    CodeMsgModel codeMsgModel = CodeMsgModel(Constant.success.toString(),S.current.success);
    return codeMsgModel;
  }

  static CodeMsgModel fail(){
    CodeMsgModel codeMsgModel = CodeMsgModel(Constant.success.toString(),S.current.fail);
    return codeMsgModel;
  }

}
